package com.org.javabody.TimerTask;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TimerTaskMethod {
	static Long count = 0L;
	
	public static void eatTimes() {
		 Runnable runnable = new Runnable() {
            @Override
            public void run() {
                ++count;
                System.out.println(count+":你是傻逼");  
            }
        };
        ScheduledExecutorService service = Executors  
                .newSingleThreadScheduledExecutor();  
        // 第二个参数为首次执行的延时时间(从当前时间开始算起)，第三个参数为定时执行的间隔时间  ，第四个单位秒
        service.scheduleAtFixedRate(runnable, 1, 5, TimeUnit.SECONDS);  
	}
	
	public static void main(String[] args) {
		eatTimes();
	}
}
